import { View } from "../../../../mvc/core/View";
import { LayerManager } from "../../../manager/LayerManager";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Global } from "../../../../../com/gengine/global/Global";
import { SoundManager } from "../../../../common/sound/SoundManager";
import { SoundTypeConst } from "../../../../common/sound/SoundTypeConst";
import { WindowLayer } from "../../../manager/WindowLayer";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class InterFlowerRewardBaseWindow
    
    export  class InterFlowerRewardBaseWindow extends View
    {
        constructor()
        {
            super();
            this._stagerect = new Object /* flash.geom.Rectangle */();
            _layer = LayerManager.windowLayer;
            LoaderHelp.addResCallBack(ResFileConst.InterFlowerRank, this.onResLoaded);
            return;
        }

        /* internal  */init(): void
        {
            this._closeBtn = ObjCreate.createGButton("", 245, 0, 19, 19, this, "CloseButton");
            this._closeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onCloseBtnClickHandler);
            this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMouseDownHandler);
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._bgA = ObjCreate.createBg(0, 0, 265, 385, this, ImagesConst.FlowerRankBgA);
            this._bgB = ObjCreate.createBg(5, 25, 255, 355, this, ImagesConst.FlowerRankBgB);
            this._flower = ObjCreate.createBitmap(ImagesConst.RewardFlower, -26, -25, this);
            this._titleBg = ObjCreate.createBitmap(ImagesConst.RankRedHead, 7, 25, this);
            this._titleBg.width = 250;
            if (this._type != 1) 
            {
                if (this._type == 2) 
                {
                    this._titleBmp = ObjCreate.createBitmap(ImagesConst.CharmTitle, 55, 25, this);
                }
            }
            else 
            {
                this._titleBmp = ObjCreate.createBitmap(ImagesConst.RewardTitle, 55, 25, this);
            }
            this.init();
            this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMouseDownHandler);
            return;
        }

        /* internal  */onCloseBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Global.stage.focus = Global.stage;
            SoundManager.instance.soundPlay(SoundTypeConst.UIclose);
            hide();
            return;
        }

        /* internal  */onMouseDownHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Global.stage.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onMouseUpHandler);
            if (typeof _layer === "windowlayer") 
            {
                this._stagerect.x = 0;
                this._stagerect.y = 0;
                this._stagerect.width = this.stage.stageWidth;
                this._stagerect.height = this.stage.stageHeight;
                this.startDrag(false, this._stagerect);
            }
            else 
            {
                this.startDrag(false);
            }
            return;
        }

        /* internal  */onMouseUpHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Global.stage.removeEventListener(flash.events.MouseEvent.MOUSE_UP, this.onMouseUpHandler);
            this.stopDrag();
            return;
        }

        protected /* var */_closeBtn: GButton;

        protected /* var */_bgA: ScaleBitmap;

        protected /* var */_bgB: ScaleBitmap;

        protected /* var */_titleBg: Object /* flash.display.Bitmap */;

        protected /* var */_flower: Object /* flash.display.Bitmap */;

        protected /* var */_titleBmp: Object /* flash.display.Bitmap */;

        protected /* var */_type: int;

        /* internal */ /* var */_stagerect: Object /* flash.geom.Rectangle */;
    }
